<?
require("config.php");

$location_status .= "| Edit";
$show_backnav = "catalog_menu";
$menuname = NULL;
$menutarget = NULL;

if (NULL!=$action){

	if ($File_name=="" || $File_name==NULL) $File_name=$old_File;

	if ($remove_File=="ture") $File_name=NULL;

   $field = array(
	"code", 
	"name", 
	"file", 
	);


   $content = array(
	$Code,
	$Name,
	$File_name,
	);

	$exp = "id=$id";

   myUpdate($table,$field,$content,$exp);

	$dir = "med_catalog/";

	myUpload($File,$File_name,$dir);


   header("location:" . $rela_path . "share/msg.php?v=47");

   exit();

}else{

  if (!checkRecord($table,$id)){

	header("location:" . $rela_path . "share/msg.php?v=9002");

	exit();
  
  }

}


$Query = "SELECT 
code,
name,
file 
FROM $table WHERE id=$id LIMIT 1";

$r=myQuery($Query);

$Code=$r[0][0];
$Name=$r[0][1];
$File=$r[0][2];

require($rela_path . "inc/header.php");

?>



<form action="" method="post" enctype="multipart/form-data" name="form1">
<input name="action" type="hidden" value="edit">
<input name="id" type="hidden" value="<?print($id)?>">
<input name="Code" type="hidden" value="<?print($Code)?>">
<input name="old_File" type="hidden" value="<?print($File)?>">



<table width="95%" border="0" align="center">
  <tr> 
    <td valign="top"><p>&nbsp; 
      <table width="100%" border="0" cellspacing="5" cellpadding="1">
        <tr>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
        <tr> 
          <td class="tdheader">Code :</td>
          <td><?print($Code)?></td>
        </tr>
        <tr> 
          <td class="tdheader">Name :</td>
          <td><input type="text" class="text" name="Name" size="40" value="<?print($Name)?>"></td>
        </tr>
        <tr> 
          <td class="tdheader">Download File :</td>
          <td>
		  <?loadFile($File,$rela_path . $PIC_DIR . "$table/")?>
		  <?removeFile($File,"remove_File")?>
		  <input type="File" class="text" name="File" size="40"></td>
        </tr>
        <tr> 
          <td>&nbsp;</td>
          <td><input type="image" src="../../images/bt_cancel.gif" onClick="Redirect('catalog_menu.php',1);return false;"> <input type="image" src="../../images/bt_save.gif"></td>
        </tr>
        <tr> 
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
      </table>
      <p>&nbsp;
      <p>&nbsp;
      <p> <br>
      <p><br>
        <br>
        <br>
        <br>
      <p>&nbsp; 
      <p>&nbsp; 
      <p>&nbsp; </td>
  </tr>
</table>
<br>
<br>
<br>
<?
require($rela_path . "inc/footer.php");
?>
